package com.llkj.qingnianguoxue.adapter;

import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.llkj.qingnianguoxue.R;
import com.llkj.qingnianguoxue.bean.RechargeBean;
import com.llkj.qingnianguoxue.util.DisplayUtil;

import java.util.List;

/**
 *  直播充值适配器
 */
public class ZhiBoRechargeAdapter extends BaseQuickAdapter<RechargeBean, BaseViewHolder> {
    private int mCheckPosition = 0;

    public ZhiBoRechargeAdapter(int layoutResId, List<RechargeBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, RechargeBean item) {
        TextView tvRechage = baseViewHolder.getView(R.id.tv_pay);
        tvRechage.setText(item.getName()+"\n"+item.getPrice()+"元");
        tvRechage.setTextSize(16);

        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tvRechage.getLayoutParams();
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        int padding = DisplayUtil.dip2px(mContext,5);
        tvRechage.setPadding(0,padding,0,padding);

        if(mCheckPosition == baseViewHolder.getLayoutPosition()){
            tvRechage.setSelected(true);
        }else{
            tvRechage.setSelected(false);
        }
    }

    public void setCheckPosition(int position) {
        mCheckPosition = position;
        notifyDataSetChanged();
    }

    public int getCheckPosition() {
        return mCheckPosition;
    }

}
